<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>注册</title>
    <link rel="stylesheet" href="css/reg.css">
    <script src="js/jquery-1.8.3.min.js"></script>
    <script src="layer/mobile/layer.js"></script>

</head>
<body>
    <div class="container">
        <div class="content">
            <form class="regForm">

                <!--电话-->
                <div class="row">
                   <label for="phone" class="regLable" name="phone">电<span style="color:#f3f3f3;">话</span>话：</label>
                    <input type="text" name="phone" class="inpVal telVal" placeholder="请输入手机号"><span readonlyunselectable="on" readonly class="sendNumBtn" >获取验证码</span>
                </div>
                <!--验证码-->
                <div class="row">
                    <label for="code" class="regLable" name="code">验证码：</label>
                    <input type="text" name="code" class="inpVal codeVal">
                    <input type="hidden" class="customerId">
                </div>
                <div class="row">
                    <input type="button" class="regBtn" value="确   定">
                </div>
            </form>
        </div>
    </div>
    <script>
        var countdown=60;
        function settime(obj) {
            if (countdown == 0) {
                obj.removeAttribute("disabled");
                obj.innerHTML="获取验证码";
                countdown = 60;
                return;
            } else {
                obj.setAttribute("disabled", true);
                obj.innerHTML=countdown +"s";
                countdown--;
            }
            setTimeout(function() {
                    settime(obj) }
                ,1000)
        }

            $(".sendNumBtn").click(function(){
                if($(".telVal").val() !== ""){
                    var re = /^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/;
                    var tel = $(".telVal").val();
                    var retu=re.test(tel);
                    if(!retu){
                        layer.open({
                            content: '请输入正确格式的手机号'
                            ,skin: 'msg'
                            ,time: 2 //2秒后自动关闭
                        });
                        $(".telVal").val("");
                        return false;
                    }else{
                        $.post("http://lkb0.lukebang.com.cn/bulu/upload/sendMaByPhone",{sendType:2,phone:tel},function(data){
                            //console.log(data);
                            /*if(data.status==0){
                                alert("验证码已发送您的手机，请注意查收！");
                                $(".regLable").attr("number",data.data);
                            }*/
                        },"json")
                        settime(this);
                        return true;
                    }
                }else{
                    layer.open({
                        content: '请输入手机号'
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                    });
                    //alert("请输入手机号");
                }
            })

        /*点击注册验证手机号*/

        //var reg = /(1[3-9]\d{9}$)/;
        //var re=new RegExp(/^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/);

        $(".regBtn").click(function(){
            var tel = $(".telVal").val();
            if($(".telVal").val() == ""){
                layer.open({
                    content: '请输入手机号'
                    ,skin: 'msg'
                    ,time: 2 //2秒后自动关闭
                });
                return false;
            }else if($(".codeVal").val() == ""){
                layer.open({
                    content: '请输入验证码'
                    ,skin: 'msg'
                    ,time: 2 //2秒后自动关闭
                });
            } else{
                var re = /^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/;
                var retu=re.test(tel);
                if(!retu){
                    //alert("请输入正确格式的手机号");
                    layer.open({
                        content: '请输入正确格式的手机号'
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                    });
                    return false;
                }else{
                    var codeNum = $(".codeVal").val();
                    var hideNum = $(".customerId").val();
                    $.post("http://192.168.0.5:8989/bulu/customer/subordinate",{customerId:1000005,phone:tel,vertifyCode:codeNum},function(data){
                        if(data.status == 0){
                            layer.open({
                                content: data.message
                                ,skin: 'msg'
                                ,time: 2 //2秒后自动关闭
                            });
                        }
                    })
                    //console.log($(".regLable").attr("number"));
                    //lalert("222");
                    return true;
                }

            }
        })
    </script>
</body>
</html>